<template>
	<view class="list">
		<view class="box" v-for="(item,index) in groupUserData" :key="index">
			<view class="box-title" v-if="item.data.length != 0 && item.id == '1'">
				<text>族长({{item.data.length}}人)</text>
			</view>
			<view class="box-title" v-else-if="item.data.length != 0 && item.id == '2'">
				<text>管理员({{item.data.length}}人)</text>
			</view>
			<view class="box-title" v-else-if="item.data.length != 0 && item.id == '3'">
				<text>成员({{item.data.length}}人)</text>
			</view>
			<view class="box-item" v-for="(n,i) in item.data" :key="i" @longpress="longpress">
				<view class="box-radio" v-if="isShow">
					<radio @click="checkedRadio(n)" :checked="n.isRadio" style="transform:scale(0.7)" color="#43CF7C">
					</radio>
				</view>
				<view class="box-con" @click="gotoUserSet(n)">
					<view class="box-con-head">
						<image :src="n.head"></image>
					</view>
					<view class="box-con-name">
						<text>{{n.nickname}}</text>
					</view>
				</view>
				<view class="box-remove" v-if="isShow" @click="removeUser(n)">
					<view class="box-remove-btn">
						<text>移除</text>
					</view>
				</view>
			</view>
		</view>

		<my-bottom-btn :title="btnTitle" :isBtnSlot="isBtnSlot" v-if="isShow">
			<template v-slot:btnSlot>
				<view class="my-btn">
					<view class="btn-remove" @click="removeUsers">踢出成员</view>
					<view class="btn-close" @click="closeBtn">取消</view>
				</view>
			</template>
		</my-bottom-btn>
	</view>
</template>

<script>
	import myBottomBtn from '@/components/common/my-bottom-btn/my-bottom-btn.vue'

	export default {
		props: ['groupUserData', 'isShow', 'groupInfo'],
		components: {
			myBottomBtn
		},
		data() {
			return {
				btnTitle: '踢出选中用户',
				isBtnSlot: true,
				userId: uni.getStorageSync('userId'),
			}
		},
		methods: {
			//1，长按弹出
			longpress() {
				// setTimeout(() => {
				// 	this.$emit('changeIsShow', true)
				// }, 100);
			},
			//2，关闭弹出
			closeBtn() {
				setTimeout(() => {
					this.$emit('changeIsShow', false)
				}, 100);
			},
			//2，选中
			checkedRadio(item) {
				this.$emit('checkedRadio', item)
			},
			//3，删除某个用户
			removeUser(item) {
				this.$emit('removeUser', item)
			},
			//4，批量删除
			removeUsers() {
				this.$emit('removeUsers')
			},
			//5，跳转用户详情页面
			gotoUserSet(item) {
				if (item.userId == this.userId) {
					//用户点击自己的头像
					return
				}

				if (this.groupInfo.protect == '1' && this.groupInfo.identity == '3') {
					//开启保护模式
					console.log('目前为群保护模式！')
					return;
				}

				var req = {
					id: item.userId,
					nickname: item.nickname,
					head: item.head,
					type: 2, //用户单聊类型
				}
				uni.navigateTo({
					url: '/subpkg/msg/user/user-describe/user-describe?msgObject=' + JSON.stringify(req),
				})
			},
		},

	}
</script>

<style lang="scss" scoped>
	.box {
		.box-title {
			// background-color: rgba(229, 229, 229, 1);
			width: 100%;
			height: 80rpx;
			line-height: 80rpx;
			background-color: #F2F2F2;
			color: #A7A6AB;

			text {
				font-size: 30rpx;
				margin-left: 30rpx;
				font-weight: 500;
			}
		}
	}

	.box-item {
		display: flex;
		width: 100%;
		// margin-left: 4%;
		height: 100rpx;

		&:active {
			background-color: #F2F2F2;
		}

		.box-radio {
			line-height: 100rpx;
		}

		.box-con {
			display: flex;
			width: 100%;

			.box-con-head {
				margin-left: 15rpx;

				image {
					margin-top: 10rpx;
					width: 80rpx;
					height: 80rpx;
					border-radius: 50%;
				}
			}

			.box-con-name {
				line-height: 100rpx;
				font-size: 32rpx;
				margin-left: 20rpx;

				text {
					overflow: hidden;
					-webkit-line-clamp: 1;
					display: -webkit-box;
					text-overflow: ellipsis;
					-webkit-box-orient: vertical;
				}
			}
		}

		.box-remove {
			width: 150rpx;

			.box-remove-btn {
				width: 100rpx;
				height: 50rpx;
				margin-top: 25rpx;
				background-color: #43CF7C;
				border-radius: 30rpx;
				text-align: center;

				text {
					color: #fff;
					font-size: 24rpx;
					line-height: 50rpx;
				}
			}
		}
	}

	.bottom {
		width: 100%;

		.remove-btn {
			width: 100%;
			position: fixed;
			height: 120rpx;

		}
	}

	.my-btn {
		width: 100%;
		position: fixed;
		left: 0;
		bottom: 0;
		height: 120rpx;
		display: flex;

		view {
			width: 40%;
			height: 80rpx;
			border-radius: 40rpx;
			text-align: center;
			line-height: 80rpx;
			color: #fff;
			font-size: 30rpx;
		}

		.btn-remove {
			background-color: #43CF7C;
			margin-left: 5%;

			&:active {
				background-color: #dbdbdb;
			}
		}

		.btn-close {
			background-color: rgba(247, 124, 153, 1);
			margin-left: 10%;

			&:active {
				background-color: #dbdbdb;
			}
		}
	}
</style>